<template>
  <div v-if="tableConfigUnitInner.loaded">
    <areaSearch
        :table-config-unit="tableConfigUnitInner"
        :page-params.sync="pageParams"
        @getPage="getPage"
    />
    <areaTable
        ref="table"
        :table-config-unit="tableConfigUnitInner"
        :page-params="pageParams"
        :tableColumnPrependCfg="{label:$t('选择'),align:'center'}"
    >
      <template #tableColumnPrepend="scope">
        <el-button type="primary" size="mini" @click="$emit('selectEntity',scope)">{{$t('选择')}}</el-button>
      </template>
    </areaTable>
  </div>
</template>

<script>
import areaTableUnitExtend from './areaTableUnitExtend.js'

export default {
  name: 'areaFormRelaEntity',
  filters: {},
  extends: areaTableUnitExtend,
  props: {
    selectEntity: {},
  },
  data() {
    return {
      moduleKey:'',
      showDialog: true,
      tableConfigUnit: {
        tableConfigs: {
          base: {
            adminButtons: ['query']
          }
        },
      },
      pageParams: {enabled:1},
    }
  },
  watch: {},
  async created() {
    await this.createdFirst()
    if (this.tableConfigUnit.entityName) {
      await this.getTableConfigDb()
    }
  },
  methods: {
    async createdFirst() {
      let strs = this.selectEntity.entityName.split('.')
      this.moduleKey = strs[0]
      this.tableConfigUnit.entityName = strs[1]
      // debugger
    },
  }
}
</script>
